package com.zhy;

import com.zhy.annotation.DemoConfig;
import com.zhy.annotation.DemoService;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

/**
 * 测试用的运行类
 * Created by zhy on 2017/4/27.
 */
public class TestMain {

    public static void main(String[] args) {
        /**
         * 测试事件监听
         */
        /*AnnotationConfigApplicationContext context =
                new AnnotationConfigApplicationContext(EventConfig.class);

        DemoPublisher demoPublisher = context.getBean(DemoPublisher.class);
        demoPublisher.publish("hello application event");
        context.close();*/

        /**
         * 测试spring aware
         */
        /*AnnotationConfigApplicationContext context =
                new AnnotationConfigApplicationContext(AwareConfig.class);
        AwareService awareService = context.getBean(AwareService.class);
        awareService.outputResult();
        context.close();*/

        /**
         * 测试线程
         */
        /*AnnotationConfigApplicationContext context =
                new AnnotationConfigApplicationContext(TaskExecutorConfig.class);
        AsyncTaskService asyncTaskService = context.getBean(AsyncTaskService.class);
        for (int i = 0; i < 10; i++) {
            asyncTaskService.executeAsyncTask(i);
            asyncTaskService.executeAsyncTaskPlus(i);
        }
        context.close();*/

        /**
         * 测试计划任务
         */
        /*AnnotationConfigApplicationContext context =
                new AnnotationConfigApplicationContext(TaskSchedulerConfig.class);*/

        /**
         * 测试@Conditional
         */
        /*AnnotationConfigApplicationContext context =
                new AnnotationConfigApplicationContext(ConditionConfig.class);
        ListService listService = context.getBean(ListService.class);
        System.out.println(context.getEnvironment().getProperty("os.name")
                + "系统下的列表命令为 ："
                + listService.showListCmd());*/

        /**
         * 测试组合注解
         */
        AnnotationConfigApplicationContext context =
                new AnnotationConfigApplicationContext(DemoConfig.class);
        DemoService demoService = context.getBean(DemoService.class);
        demoService.outputResult();
        context.close();
    }

}
